package com.macro.mall.service.impl;

import com.github.pagehelper.PageHelper;
import com.macro.mall.mapper.SmsCouponHistoryMapper;
import com.macro.mall.model.SmsCouponHistory;
import com.macro.mall.model.SmsCouponHistoryExample;
import com.macro.mall.service.SmsCouponHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * @author Administrator
 * @date 2020/5/30
 * @since
 */
@Service
public class SmsCouponHistoryServiceImpl implements SmsCouponHistoryService {
	@Autowired
	private SmsCouponHistoryMapper historyMapper;
	@Override
	public List<SmsCouponHistory> list(Long couponId, Integer useStatus, String orderSn, Integer pageSize, Integer pageNum) {
		PageHelper.startPage(pageNum,pageSize);
		SmsCouponHistoryExample example = new SmsCouponHistoryExample();
		SmsCouponHistoryExample.Criteria criteria = example.createCriteria();
		if(couponId!=null){
			criteria.andCouponIdEqualTo(couponId);
		}
		if(useStatus!=null){
			criteria.andUseStatusEqualTo(useStatus);
		}
		if(!StringUtils.isEmpty(orderSn)){
			criteria.andOrderSnEqualTo(orderSn);
		}
		return historyMapper.selectByExample(example);
	}

}
